class
<stdexcept>

std::domain_error

class domain_error;
Domain error exception

This class defines the type of objects thrown as exceptions to report domain errors.

Generally, the domain of a mathematical function is the subset of values that it is defined for. For example, the square root function is only defined for non-negative numbers. Thus, a negative number for such a function would qualify as a domain error.

No component of the standard library throws exceptions of this type. It is designed as a standard exception to be thrown by programs.

1
2
3
4
class domain_error : public logic_error {
public:
 explicit domain_error (const string& what_arg);
};
1
2
3
4
5
class domain_error : public logic_error {
public:
 explicit domain_error (const string& what_arg);
 explicit domain_error (const char* what_arg);
};

Members

constructor
The string passed as what_arg has the same content as the value returned by member what .

The class inherits the what member function from logic_error .

Exception safety

Strong guarantee: if the constructor throws an exception, there are no side effects.

See also

exception
Standard exception class (class)
logic_error
Logic error exception (class)
runtime_error
Runtime error exception (class)
invalid_argument
Invalid argument exception (class)
length_error
Length error exception (class)
out_of_range
Out-of-range exception (class)

AltStyle によって変換されたページ (->オリジナル) /